package com.lw.springmvc.advice;

import com.lw.springmvc.excetions.MyBaseException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/3/8 20:01
 */
@ControllerAdvice
@ResponseBody
public class MyControllerAdvice {

    @ExceptionHandler(MyBaseException.class)
    public String processException(MyBaseException e){
        return e.getMessage();
    }

    @ExceptionHandler(Exception.class)
    public String processException(Exception e){
        return e.getMessage();
    }
}
